<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <script type="text/javascript">
      // 普通函数和构造函数的区别
      
      // 创建一个对象的工厂模式
      function createObject(name,age){
        var obj = new Object();
        obj.name = name;
        obj.age = age;
        return obj;
      }
      
      var p = createObject('tom',18);
      console.log(p.name);
      
      // 构函数可以看出类型
      function Person(name,age){
        this.name = name;
        this.age = age;
      }
      
      var p1 = new Person('lily',16);
      console.log(p1.name)
      
      
      
    </script>
  </body>
</html>
